<include file="public@header"/>
<style>
    /*table{ border:1px solid #000; width:80%; font-size:1rem; margin-bottom:20px}
    td{border:1px solid #000; padding:0 5px; height:2rem; text-align:center}*/


    .content_nav .check_info {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .form-horizontal .control-group1.group_left {
        width: 50%;
    }

    .form-horizontal .group_left .control-label {
        width: 90px;
    }

    .form-horizontal .group_left .controls {
        margin-left: 100px;
    }

    .form-horizontal .control-group1 {
        float: left;
        width: 15%;
        margin-bottom: 20px;
    }

    .form-horizontal .control-label {
        width: 80px;
    }

    .form-horizontal .controls {
        margin-left: 90px;
    }
</style>
</head>
<body>
<php>$page='';$vo['id']='';</php>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Aftersale/protect')}">管理费业务</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form" action="{:url('')}" method="post">
        <fieldset>
            <div class="div_title"><span>客户概览</span></div>
            <div class="control-group1-p div_content">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label" >客户姓名</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" value="{$result.buyer_name}" disabled>
                        </div>
                        <label class="control-label">持证类型</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" value="{:cart_type('cart',$result.cart_type)}" disabled>
                        </div>
                        <label class="control-label">证件号码</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" value="{$result.customer_account}" disabled>
                        </div>
                        <label class="control-label">联系电话</label>
                        <div class="col-md-2" style="width: 10.5%">
                            <input type="text" class="form-control" value="{$result.buyer_phone}" disabled>
                        </div>
                        <label class="control-label">联系地址</label>
                        <div class="col-md-4" style="width: 31.5%;">
                            <input type="text" class="form-control" value="{$result.customer_address}" style="width:80%;" disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">合同编号</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" value="{$result.contract_sn}" disabled>
                        </div>
                        <label class="control-label">购买日期</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" value="{$result.gm_start_time}" disabled>
                        </div>
                        <label class="control-label">打证日期</label>
                        <div class="col-md-2"style="width: 11%">
                            <input type="text" class="form-control" value="{$result.dz_start_time}" disabled>
                        </div>
                        <label class="control-label">维护期起</label>
                        <div  class="col-md-2"style="width: 11%">
                            <input type="text" class="form-control" value="{$result.start_whq_date}" disabled>
                        </div>
                        <label class="control-label">维护期止</label>
                        <div class="col-md-2" style="width: 13%">
                            <input type="text" class="form-control" value="{$result.end_whq_time}" disabled>
<!--                            <a>修改</a>-->
                        </div>

                        <label class="control-label" style="width: 50px">状态</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" value="{$result.whq_status}" disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">墓位编号</label>
                        <div class="col-md-2" style="width: 13%">
                            <input type="text" class="form-control" style="width: 100%" value="{$result.tomb_num}" disabled>
                        </div>
                        <label class="control-label" style="width: 57px;">具体位置</label>
                        <div class="col-md-2" style="width: 28%">
                             <input type="text" class="form-control" style="width:100%;" value="{$result.tomb_region}{$result.tomb_address}" disabled>
                         </div>
                        <label class="control-label" style="width: 57px;">墓穴规制</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" style="width:80%;"  value="{$result.tomb_regulation_name}" disabled>
                        </div>
                        <label class="control-label" style="width:81px;">当前状态</label>
                        <div class="col-md-2" style="width: 11%">
                            <input type="text" class="form-control" style="width:100px;" value="{$result.col_status_name}" disabled>
                        </div>
                        <label class="control-label" style="width:81px;">占地面积</label>
                        <div class="col-md-2"  style="width: 11%">
                            <input type="text" class="form-control" style="width:130px;" value="{$result.footprint}㎡" disabled>
                        </div>
                    </div>
                </div>

                <!---tab页-->
                <ul class="nav_tabs">
                    <li class="active"><a href="javascript:">续费登记</a></li>
                    <li><a href="javascript:;">续费记录</a></li>
                </ul>
                <div class="control-group1-p nav_content">
                    <div class="content_nav">
                        <div class="p_title">
                            <span class="span_title">续费人信息</span>
                        </div>
                        <div class="control-group1-p"
                             style="border:1px solid #e2e2e2; padding-top:20px;margin:0 20px;overflow:hidden; overflow-x:auto;">
                            <table class="table table-hover table-bordered">
                                <thead>
                                <tr>
                                    <th>办理人</th>
                                    <th>性别</th>
                                    <th>手机号码</th>
                                    <th></th>
                                    <th>关系</th>
                                    <th>证件类型</th>
                                    <th>证件号码</th>
                                    <th>联系地址</th>
                                    <th>证件上传</th>
                                    <th>经办人</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td>
                                        <input type="text" class="form-control" name="dealer" required style="width: 120px">
                                    </td>
                                    <td>
                                        <select name="sex" class="form-control" required>
                                            <option value="1">男</option>
                                            <option value="2">女</option>
                                        </select>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" name="phone" value="" required style="width: 120px">
                                    </td>
                                    <td>
                                        <div style="width: 100px"><input type="checkbox" name="is_sms" value="1" style="width: 20px;">短信通知</div>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" name="relation" value="" required style="width: 120px">
                                    </td>
                                    <td>
                                        <select name="card_ytpe" class="form-control">
                                            <option value="1">身份证</option>
                                            <option value="2">港澳身份证</option>
                                            <option value="3">护照</option>
                                            <option value="4">军人证</option>
                                        </select>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" name="cart_num" value="" required>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control address" name="address" value="" required>
                                    </td>
                                    <td>
                                        <php>$img_ht=cmf_get_image_preview_url(isset($retreat['card_file'])?$retreat['card_file']:'');</php>
                                        <input type="hidden" name="card_file" id="ht_file" value="{$retreat.ht_file|default=''}">
                                        <a href="javascript:gpyUploadOneImage('上传证件', '#ht_file','{$result.tomb_num}');">
                                            <h5 class="btn btn-primary">拍照上传</h5>
                                        </a>
                                        <img src="{$img_ht}" style="cursor: pointer; height: 50px" onclick="parent.imagePreviewDialog(this.src);" id="ht_file-preview" class="preview" style="cursor: hand; height: 50px"/>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" value="{:cmf_get_admin_name()}" disabled style="width: 100px">
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="p_title">
                            <span class="span_title">缴费详情</span>
                        </div>
                        <div class="control-group1-p"
                             style="border:1px solid #e2e2e2; padding-top:20px;margin:0 20px;overflow:hidden; overflow-x:auto;">
                            <table class="table table-hover table-bordered">
                                <thead>
                                <tr>
                                    <th>单价标准</th>
                                    <th>续费时长(年)</th>
                                    <th>政策减免</th>
                                    <th>应收总计</th>
                                    <th>付款方式</th>
                                    <th>办理人</th>
                                    <th>收费时间</th>
                                    <!--<th>收费复核</th>-->
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td>
                                        <label style="font-weight: normal;" class="manager_price">{$costset.manager_cost}</label>
                                        <input type="hidden" id="manager_cost"   name="manager_price"  value="{$costset.manager_cost}" />
                                    </td>
                                    <td>
                                        <select name="duration" class="form-control" id="duration">
                                            <for start="1" end="11" step="1" >
                                                <option value="{$i}">{$i}</option>
                                            </for>
                                        </select>
                                    </td>
                                    <td><select name="free_reduce" class="form-control " id="free_reduce">
                                        <for start="0" end="600" step="100" >
                                            <option value="{$i}">{$i}</option>
                                        </for>
                                    </select>
                                    </td>
                                    <td><input type="text" class="form-control " id="total_price" name="total_price" value="{$costset.manager_cost}"></td>
                                    <td><select name="pay_type" class="form-control">
                                        <option value="1">现金</option>
                                        <option value="2">微信</option>
                                    </select>
                                    </td>
                                    <td><input type="text" class="form-control" name="dealers" value="{:cmf_get_admin_name()}" ></td>
                                    <td><input type="text" class="form-control js-datetime" name="pay_time" value="{$pay_time}" autocomplete="off">
                                    </td>
                                    <!--<td>-->
                                        <!--<div class="btn btn-primary" id="chn">确认收款</div>-->
                                    <!--</td>-->
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="form-actions">
                            <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('提交')}</button>
<!--                            <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>-->
                        </div>
                       <!-- <div class="form-actions">
                            <div class="btn btn-primary" id="btn1">打印结算单</div>
                            <div class="btn btn-primary" id="che">打证预览</div>
                        </div>-->
                    </div>


                    <div class="content_nav feature">
                        <div class="p_title">
                            <span class="span_title">续费记录</span>
                        </div>
                        <div class="control-group1-p"
                             style="border:1px solid #e2e2e2; padding-top:20px;margin:0 20px;overflow:hidden; overflow-x:auto;">
                            <table class="table table-hover table-bordered"
                                   style="max-width: 120% !important;width: 120% !important;">
                                <thead>
                                <tr>
                                    <td width="20">
                                        <input type="checkbox" class="js-check-all" data-direction="y"
                                               data-checklist='orderid'/>
                                    </td>
                                    <th>续费时间</th>
                                    <th>办理人姓名</th>
                                    <th>办理人性别</th>
                                    <th>手机号码</th>
                                    <th>证件号码</th>
                                    <th>证件类型</th>
                                    <th>证件上传</th>
                                    <th>与逝者关系</th>
                                    <th>续费时长</th>
                                    <th>单价标准</th>
                                    <th>政策减免</th>
                                    <th>实收金额</th>
                                    <th>收款人</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="protect_payment" item="vo">
                                    <tr>
                                        <td width="20">
                                            <input type="checkbox" class="js-check-all" data-direction="y"
                                                   data-checklist='orderid'/>
                                        </td>
                                        <td> {$vo.pay_time|date="Y-m-d H:i:s"}</td>
                                        <td>{$vo.dealer}</td>
                                        <td>
                                            <if ($vo.sex)==1>男
                                                <else/>女
                                            </if>
                                        </td>
                                        <td>{$vo.phone}</td>
                                        <td>{$vo.cart_num}</td>
                                        <td>{:cart_type('cart',$vo.card_ytpe)}</td>
                                        <td> <img src="{:cmf_get_image_preview_url($vo.card_file)}"  width="50" style="cursor: hand"/></td>
                                        <td>与逝者关系</td>
                                        <td>{$vo.duration}</td>
                                        <td>{$vo.manager_price}</td>
                                        <td>{$vo.free_reduce}</td>
                                        <td>{$vo.total_price}</td>
                                        <td>{$vo.pay_user}</td>
                                    </tr>
                                </foreach>
                                </tbody>
                            </table>
                        </div>
                        <div class="form-actions">
                            <div class="btn btn-primary" id="checn">补打结算单</div>
                            <div class="btn btn-primary" id="k-btn">补打登记</div>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
    <iframe id="printf" src="" width="0" height="0" frameborder="0"></iframe>

    <script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
    <script type="text/javascript">
        //切换显示
        $(document).on('click', '.nav_tabs li', function () {
            $(this).addClass('active').siblings().removeClass('active');
            var index = $(".nav_tabs li").index(this);
            billtype = index;
            console.log(index);
            $('.content_nav').eq(index).removeClass("feature").siblings().addClass("feature");
        });

        $('#duration').change(function () {
            var manager_cost = $("#manager_cost").val();
            console.log(manager_cost)
            var duration = $(this).val();
            var free_reduce = $("#free_reduce").val();
            var total_price = (manager_cost*duration)-parseInt(free_reduce) ;
            $('#total_price').val(total_price.toFixed(2))

        });
        $('#free_reduce').change(function () {
            var manager_cost = $("#manager_cost").val();
            console.log(manager_cost)
            var duration = $('#duration').val();
            var free_reduce = $("#free_reduce").val();
            var total_price = (manager_cost*duration)-parseInt(free_reduce) ;
            $('#total_price').val(total_price.toFixed(2))
        }) ;
        // 提交订单
        $("#check-btn").click(function () {
            $.post($("form").attr('action'), $("form").serialize(), function (result) {
                if (result.state == 'success') {
                    alert("保存成功！");
                    $('#js-dialog-close').click();
                } else {
                    alert(result.info);
                }
            }, 'json');
        });
        $('#btn1').on('click',function(){
            $.post("{:url('Stamp/print_cert')}",{'type':7,'mark':2,'itype':4},function(result){
                if(result.status==1){
                    var f = document.getElementById('printf');
                    f.contentDocument.write(result.html);
                    f.contentDocument.close();
                    f.contentWindow.print();
                    return false;
                }
            },'json')
        })

    </script>

</body>
</html>